import store from '../store'

export const userService ={
    checkUser: (userId, password) => {
        if(userId === 'admin' && password === '123456') {
            let userInfo = {
                userId: '',
                userName: 'YULang',
                password: '',
                bankcard: null,
            }
            userInfo.userId = userId;
            userInfo.password = password;
            store.commit('user/saveUserState', userInfo);
            return true
        }
        return false;
    },

    userLogOut: () => {
        store.commit('clearALL');
    },

    getUserInfo: () => {
        let userInfo = {
            userId: '',
            userName: '',
            bankcard: null,
            password: ''
        }
        userInfo.userName = store.getters['user/userName'];
        userInfo.userId = store.getters['user/userId'];
        userInfo.bankcard = store.getters['user/bankcard'];
        userInfo.password = store.getters['user/password'];
        return userInfo;
    },
    
    checkUserIslogin: () => {
        if(store.getters['user/userId']) {
            return true;
        } else {
            return false;
        }
    }
}